{$CLEO .cs}
0000:

const
    GANG1_ = 0@
    GANG2_ = 1@
    GANG3_ = 2@
    GANG4_ = 3@
    CAR_ = 4@
    model_name = 5@ 
    npc = 6@
    victim = 7@
    marker_1 = 8@
end

    
    
    model.Load(#HUNTLEY)
    model.Load(#STAFFORD)
    model.Load(#PREMIER)
    model.Load(#VLA2)
    model.Load(#VLA1)
    model.Load(#VLA3)
    model.Load(#AK47)
    model.Load(#TEC9)
    load_requested_models
    
    
    while true 
    wait 0
    0209: 17@ = random_int_in_ranges 0 10
    0208: 20@ = random_float_in_ranges -110.2 110.2
    0208: 21@ = random_float_in_ranges -110.2 110.2 
    04C4: store_coords_to 24@ 25@ 26@ from_actor player1 with_offset 20@ 21@ 0.0 

    02C1: store_to 27@ 28@ 29@ car_path_coords_closest_to 24@ 25@ 26@ 
    0AE1: victim = random_char_near_point 0.0 0.0 0.0 in_radius 9999999999.0 find_next 1 pass_deads 1
    if   and 
    is_key_pressed 123
    is_key_pressed 20
    then
        if and
          actor_defined   GANG1_
          actor_defined   GANG2_
          actor_defined   GANG3_
          actor_defined   GANG4_    
        then
             actor.RemoveReferences(GANG1_)
             actor.RemoveReferences(GANG2_)
             actor.RemoveReferences(GANG3_)
             actor.RemoveReferences(GANG4_)
            if car_defined  CAR_
            then
               car.RemoveReferences(CAR_ )
            end
                                     
        end    
        show_text_highpriority "Gang spawns cleared up" 2000
        break
    end
    if and
      actor_defined   GANG1_
      actor_defined   GANG2_
      actor_defined   GANG3_
      actor_defined   GANG4_    
    then
          if and
          8104: not  actor $PLAYER_ACTOR near_actor GANG1_ radius 70.0 70.0 70.0 sphere 0
          8104: not  actor $PLAYER_ACTOR near_actor GANG2_ radius 70.0 70.0 70.0 sphere 0
          8104: not  actor $PLAYER_ACTOR near_actor GANG3_ radius 70.0 70.0 70.0 sphere 0
          8104: not  actor $PLAYER_ACTOR near_actor GANG4_ radius 70.0 70.0 70.0 sphere 0
          then
             actor.RemoveReferences(GANG1_)
             actor.RemoveReferences(GANG2_)
             actor.RemoveReferences(GANG3_)
             actor.RemoveReferences(GANG4_)
             jump @To 
             
             
          end
          if and
          actor.Dead(GANG1_ )
          actor.Dead(GANG2_ )
          actor.Dead(GANG3_ )
          actor.Dead(GANG4_ )
          then
             actor.RemoveReferences(GANG1_)
             actor.RemoveReferences(GANG2_)
             actor.RemoveReferences(GANG3_)
             actor.RemoveReferences(GANG4_)
             jump @To 
          end
    end 
    :to
    if 17@==0
    then model_name=#HUNTLEY
    end
    if 17@==1
    then model_name=#STAFFORD
    end
    if 17@==2
    then model_name=#PREMIER
    end
    ////////////////////////
            if and
            
            not actor_defined   GANG1_
            not actor_defined   GANG2_
            not actor_defined   GANG3_
            not actor_defined   GANG4_
            then
                //clear old car 
                if car_defined  CAR_
                then
                    marker.Disable(8@)
                   car.RemoveReferences(CAR_ )
                end
                
                
                
                
                if and
                model.Available( #HUNTLEY  )
                model.Available( #STAFFORD  )
                model.Available( #PREMIER  )
                model.Available( #VLA1  )
                model.Available( #VLA2  )
                model.Available( #VLA3  )
                
                then
                    CAR_=car.Create(#HUNTLEY,  27@,28@ ,29@ )
                    car.Health( CAR_ ) = 6000
                    09C4: set_car CAR_ gas_tank_explosion_enabled 0

                    GANG1_=actor.CreateAsDriver(10, #VLA1,CAR_)
                    GANG2_=actor.CreateAsPassenger(10, #VLA2,CAR_,0)
                    GANG3_=actor.CreateAsPassenger(10, #VLA1,CAR_,1)
                    GANG4_=actor.CreateAsPassenger(10, #VLA3,CAR_,2)
                    actor.GiveWeaponAndAmmo(GANG1_,tec9,999999)
                    actor.GiveWeaponAndAmmo(GANG2_,ak47,999999)
                    actor.GiveWeaponAndAmmo(GANG3_,tec9,999999)
                    actor.GiveWeaponAndAmmo(GANG4_,ak47,999999)
                    0085: npc = GANG1_ // (int)
                    gosub @stats
                    0085: npc = GANG2_ // (int)
                    gosub @stats
                    0085: npc = GANG3_ // (int)
                    gosub @stats
                    0085: npc = GANG4_ // (int)
                    gosub @stats
                    car.SetToPsychoDriver(car_)
                    car.SetMaxSpeed(car_,15.0)
                    Marker.CreateAboveCar(8@,CAR_)
                    018B: set_marker 8@ radar_mode 2

                end
            end
        /////////////////////
        
        if is_actor_defined victim
        then
             if
             car_defined CAR_
             then
             
                if  051C:   car CAR_ damaged_by_actor victim 
                then
                00AE: set_car CAR_ traffic_behaviour_to 2

                    054F: clear_car CAR_ damage
                    actor.StorePos( victim, 11@,12@,13@)
                    if 056D:   actor GANG1_ defined
                    then
                        0713: actor GANG1_ driveby_actor victim car -1 point 0.0 0.0 0.0 radius 500.0 4 1 firing_rate 100

                        0615: define_AS_pack_begin 15@
                        
                        05D1: AS_actor  -1 drive_car -1  to 11@ 12@ 13@ speed 200.0 0 model #NULL 5
                        05E2: AS_actor  -1 kill_actor victim

                        0616: define_AS_pack_end 15@
                        0618: assign_actor GANG1_ to_AS_pack 15@
                        061B: remove_references_to_AS_pack 15@
                        if 056D:   actor GANG2_ defined
                        then
                           0713: actor GANG2_ driveby_actor victim car -1 point 0.0 0.0 0.0 radius 500.0 4 1 firing_rate 100
                        end                   
                        if 056D:   actor GANG3_ defined
                        then
                           0713: actor GANG3_ driveby_actor victim car -1 point 0.0 0.0 0.0 radius 500.0 4 1 firing_rate 100
                        end                   
                        if 056D:   actor GANG4_ defined
                        then
                           0713: actor GANG4_ driveby_actor victim car -1 point 0.0 0.0 0.0 radius 500.0 4 1 firing_rate 100
                        end                   

                    end  
                end 
             end

        end
        
        if and
        car_defined car_
        056D:   actor GANG1_ defined
        056D:   actor GANG2_ defined
        056D:   actor GANG3_ defined
        056D:   actor GANG4_ defined
        then
        {
            if and 
            not actor.Driving( GANG1_ )
            not actor.Driving( GANG2_ )
            not actor.Driving( GANG3_ )
            not actor.Driving( GANG4_ )
            then
                0633: AS_actor GANG1_ exit_car
                0633: AS_actor GANG2_ exit_car
                0633: AS_actor GANG3_ exit_car
                0633: AS_actor GANG4_ exit_car

            end      }
           if and
                actor.Driving(GANG1_)
                actor.Driving(GANG2_)
                actor.Driving(GANG3_)
                actor.Driving(GANG4_)
           then
               if 051C:   car car_ damaged_by_actor $PLAYER_ACTOR
               then
                    car.DriveTo()
                  054F: clear_car car_ damage
                  05E2: AS_actor GANG1_ kill_actor $PLAYER_ACTOR
               end
               if coop
               then
                   if 051C:   car car_ damaged_by_actor player2
                   then
                      054F: clear_car car_ damage
                      05E2: AS_actor GANG1_ kill_actor player2
                   end               
               end 
           end
            
            if is_actor_defined victim
            then
                
                if and 
                actor.Driving(GANG1_)
                actor.Driving(GANG2_)
                actor.Driving(GANG3_)
                actor.Driving(GANG4_)
                 00FE:   actor GANG1_ sphere 0 in_sphere  11@ 12@ 13@   radius 10.0 10.0 10.0
                 00FE:   actor GANG2_ sphere 0 in_sphere  11@ 12@ 13@   radius 10.0 10.0 10.0
                 00FE:   actor GANG3_ sphere 0 in_sphere  11@ 12@ 13@   radius 10.0 10.0 10.0
                 00FE:   actor GANG4_ sphere 0 in_sphere  11@ 12@ 13@   radius 10.0 10.0 10.0
                then
                     05E2: AS_actor GANG1_ kill_actor victim
                     05E2: AS_actor GANG2_ kill_actor victim
                     05E2: AS_actor GANG3_ kill_actor victim
                     05E2: AS_actor GANG4_ kill_actor victim
                end   
            end        
        end
        
    end 
    
 marker.Disable(8@)    
 terminate_this_custom_script

:stats
if actor_defined npc 
return_if_false
       actor.Health(npc)=300
       actor.WeaponAccuracy(npc)=60
       07DD: set_actor npc attack_rate 75 // previously known as temper_to
       0446: set_actor npc dismemberment_possible 0
       077A: set_actor npc acquaintance 4 to_actors_pedtype 0 // see ped.dat
       077A: set_actor npc acquaintance 4 to_actors_pedtype 1 // see ped.dat
       077A: set_actor npc acquaintance 4 to_actors_pedtype 6 // see ped.dat
       077A: set_actor npc acquaintance 4 to_actors_pedtype 5 // see ped.dat
       077A: set_actor npc acquaintance 4 to_actors_pedtype 4 // see ped.dat
      09B5: set_actor npc signal_after_kill 0

return